package ltd.flyweight.liquibasehelper.utils;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.Properties;

public class PropertiesUtils {

    public static Properties loadProperties(String fileName) throws IOException {
        Resource resource = new ClassPathResource(fileName);
        Properties properties = new Properties();
        try (InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream(), Charset.defaultCharset())) {
            properties.load(inputStreamReader);
        }
        return properties;
    }

}
